﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Topic.aspx.cs" Inherits="Meeting.Web.Admin.Topic.Topic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>议题管理</title>
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/main.css" />
    <script src="../../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../Scripts/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../Scripts/common.js"></script>
    <script type="text/javascript">
        $(function () {
            if (request("psnID") == "") window.location = defaultUrl;
            //初始化列表
            $('#mainList').datagrid({
                url: 'TopicOperation.ashx?method=GetAllTopic',
                singleSelect: true,
                collapsible: false,
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20  //默认一页数据条数
            });
            //设置分页
            var p = $("#mainList").datagrid("getPager");
            $(p).pagination({
                pageSize: 20, //每页显示的记录条数，默认为10   
                pageList: [10, 20, 30], //可以设置每页记录条数的列表   
                beforePageText: '第', //页数文本框前显示的汉字   
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
            });
        });
        //
        function DoSearch() {
            $('#mainList').datagrid('reload', {
                Name: $("#fName").val(),
                Begin: $("#txtBeginTime").val(),
                End: $("#txtEndTime").val()
            });
        } 
    </script>
    <style type="text/css">
        input
        {
            height: 18px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table class="SearchTable">
        <tr>
            <td>
                标题:
            </td>
            <td>
                <input id="fName" style="width: 120px;" class="easyui-validatebox" />
            </td>
            <td>
                创建时间:
            </td>
            <td>
                <input id="txtBeginTime" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                    style="width: 120px" />
            </td>
            <td>
                ~
            </td>
            <td>
                <input id="txtEndTime" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                    style="width: 120px" />
            </td>
            <td>
                <a href="#" class="easyui-linkbutton" onclick="DoSearch();">查询</a>
            </td>
        </tr>
    </table>
    <div style="min-height: 500px; text-align: left;">
        <table id="mainList" class="easyui-datagrid" nowrap="false" style="width: 1150px;">
            <thead>
                <tr>
                    <th data-options="field:'Id',width:120,hidden:true">
                    </th>
                    <th data-options="field:'CategoryId',width:120,hidden:true">
                    </th>
                    <th data-options="field:'Title',width:500">
                        标题
                    </th>
                    <th data-options="field:'EmployeeName',width:80 ">
                        主讲人
                    </th>
                    <th data-options="field:'CreateTime',width:120 ">
                        创建时间
                    </th>
                    <th data-options="field:'Agent',width:60 ">
                        经办人
                    </th>
                    <th data-options="field:'IsSubmit1',width:80,formatter:formatStatus ">
                        议题状态
                    </th>
                    <th data-options="field:'IsSubmit',width:60,formatter:formatIsSubmit ">
                        上会管理
                    </th>
                    <th data-options="field:'actionColumn1',width:70,formatter:formatTopicDelete">
                        删除议题
                    </th>
                    <th data-options="field:'nCount', hidden:true">
                         
                    </th>
                </tr>
            </thead>
        </table>
        <script type="text/javascript">

            function formatStatus(val, row, rowIndex) {

                if (row.IsSubmit == false) {
                    return "未提交上会";
                }
                else {
                    if (row.nCount > 0) {
                        return "已开会讨论";
                    } else {
                    return "已提交上会";
                    }
//                    var postData = { Id: row.Id };
//                    $.post("TopicOperation.ashx?method=IsDiscuss", postData, function (data) {
//                        var str = ;
//                        if (data.success == true) {
//                            str = "已开会讨论";
//                        }
//                        row.IsSubmit1 = str;
//                        $('#mainList').datagrid('updateRow', {
//                            index: rowIndex,
//                            row: row
//                        });
//                    });
                }

            }

            //议题状态
            function formatIsSubmit(val, row) {
                if (row.IsSubmit == true) {
                    return "<a href='#' class='easyui-linkbutton' onclick=\"UnSubmit('" + row.Id + "');\"  >撤销上会</a> ";
                }
                else {
                    return "<a href='#' class='easyui-linkbutton' onclick=\"IsSubmit('" + row.Id + "');\"  >提交上会</a> ";
                }
            }
            function IsSubmit(id) {
                var postData = { Id: id };
                $.post("TopicOperation.ashx?method=IsSubmit", postData, function (data) {
                    if (data.success == true) {
                        $.messager.alert("提示", "上会成功");
                        $("#mainList").datagrid("reload");
                    } else {
                        $.messager.alert("提示", "上会失败:" + data.Message);
                    }
                });
            }
            function UnSubmit(id) {

                $.messager.confirm("询问", "撤销上会，确定吗？", function (c) {
                    if (!c) return;
                    var postData = { Id: id };
                    $.post("TopicOperation.ashx?method=UnSubmit", postData, function (data) {
                        if (data.success == true) {
                            $.messager.alert("提示", "撤销成功");
                            $("#mainList").datagrid("reload");
                        } else {
                            $.messager.alert("提示", "撤销失败:" + data.Message);
                        }
                    });
                });


            }
            //删除议题
            function formatTopicDelete(val, row) {
                return "<a href='#' class='easyui-linkbutton' onclick=\"DeleteTopic('" + row.Id + "'," + row.IsSubmit + ");\"  >删除</a> ";
            }
            function DeleteTopic(id, isSubmit) {
                if (isSubmit == true) {
                    $.messager.alert("提示", "该议题已经提交上会，请撤销上会后再进行删除！");
                    return;
                }
                $.messager.confirm("询问", "该议题将被永久删除，确定吗？", function (c) {
                    if (!c) return;
                    var postData = { Id: id };
                    $.post("TopicOperation.ashx?method=DeleteTopic", postData, function (data) {
                        if (data.success == true) {
                            $.messager.alert("提示", "删除成功");
                            $("#mainList").datagrid("reload");
                        } else {
                            $.messager.alert("提示", "删除失败:" + data.Message);
                        }
                    });
                });
            }
            
        </script>
    </div>
    </form>
</body>
</html>
